Skip to content

feat(python): activate dynamic plugins#365

Draft
bbednarski9 wants to merge 9 commits into
NVIDIA:mainfrom
bbednarski9:bbednarski/python-dynamic-plugin-host
Draft

feat(python): activate dynamic plugins#365
bbednarski9 wants to merge 9 commits into
NVIDIA:mainfrom
bbednarski9:bbednarski/python-dynamic-plugin-host

Conversation

@bbednarski9

@bbednarski9 bbednarski9 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Overview

This adds an owned Python binding for explicit native and worker dynamic-plugin activation. It is stacked on #364; once that PR lands, this diff reduces to the Python binding and its tests.

Static-only harness-native applications keep using plugin.initialize() / plugin.clear(). activate_dynamic_plugins(...) requires at least one dynamic specification; its base config may also contain static components, which initialize before components appended by the dynamic plugins.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Add DynamicPluginActivationSpec and async activate_dynamic_plugins(...) to nemo_relay.plugin.
  • Return an owned PluginHostActivation with the successful validation report and active-state inspection.
  • Support async close(), async with, and best-effort finalization without blocking the Python finalizer or holding the GIL during teardown.
  • Share one cancellation-resistant close operation across repeated or concurrent callers; every caller observes the same cached result.
  • Preserve nested Python None values as JSON null in plugin configuration while still omitting optional top-level specification fields.
  • Preserve the existing static plugin.initialize() and plugin.clear() APIs. Empty dynamic activation is rejected without claiming process ownership, so static initialization remains available.
  • Map invalid config, missing manifests, ownership conflicts, registration failures, and teardown failures to ordinary Python exceptions.
  • Add neutral native and worker fixture coverage for callbacks, mixed static/dynamic configuration, conflicts, partial-load rollback, explicit close, context cleanup, concurrent close, cancellation, and finalization.

Where should the reviewer start?

Start with python/nemo_relay/plugin.py for the public API and crates/python/src/py_plugin.rs for shared ownership, cancellation-resistant cleanup, and exception translation. End-to-end fixture cases are in python/tests/test_dynamic_plugin_host.py.

Validation

  • python/tests/test_dynamic_plugin_host.py — 10 passed
  • cargo fmt --all -- --check
  • cargo clippy -p nemo-relay-python --all-targets -- -D warnings
  • Ruff check and format passed
  • The earlier full non-integration Python suite passed (505 tests)
  • git diff --check

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Relates to #364.

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 1232b8c0-152c-4a44-a480-5ae22f0de6ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XL PR is extra large Feature a new feature lang:python PR changes/introduces Python code lang:rust PR changes/introduces Rust code labels Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9 bbednarski9 force-pushed the bbednarski/python-dynamic-plugin-host branch from a252f6a to 9615c1d Compare July 7, 2026 00:32
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

License Diff

Compared against origin/main.

Lockfile license changes

Lockfile License Changes

Rust

Added

  • None

Removed

  • None

Updated/Changed

  • None

Node

Added

  • None

Removed

  • None

Updated/Changed

  • None

Python

Added

  • None

Removed

  • None

Updated/Changed

  • None
Status output
[license-diff] selected languages: rust, node, python
[license-diff] generating current inventory
[license-diff] current: generating Rust inventory
[license-diff] current: Rust inventory complete (378 packages)
[license-diff] current: generating Node inventory
[license-diff] current: Node inventory complete (363 packages)
[license-diff] current: generating Python inventory
[license-diff] current: Python inventory complete (105 packages)
[license-diff] current inventory complete
[license-diff] checking out base ref origin/main into a temporary worktree
[license-diff] base: generating Rust inventory
[license-diff] base: Rust inventory complete (378 packages)
[license-diff] base: generating Node inventory
[license-diff] base: Node inventory complete (363 packages)
[license-diff] base: generating Python inventory
[license-diff] base: Python inventory complete (105 packages)
[license-diff] base inventory complete
[license-diff] removing temporary base worktree
[license-diff] comparing inventories
[license-diff] rendering Markdown output
[license-diff] done

Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9 bbednarski9 force-pushed the bbednarski/python-dynamic-plugin-host branch from 9615c1d to 8263c93 Compare July 7, 2026 14:17
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
@bbednarski9 bbednarski9 force-pushed the bbednarski/python-dynamic-plugin-host branch from 8263c93 to d2a1746 Compare July 7, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature a new feature lang:python PR changes/introduces Python code lang:rust PR changes/introduces Rust code size:XL PR is extra large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants